package org.example;

public class Test1 {
    //leetcode 55 跳跃游戏 https://leetcode.cn/problems/jump-game/description/
    public boolean canJump(int[] nums) {
        int n = nums.length, max = 0;
        for (int i = 0; i < n; i++) {
            if (max < i) return false;
            max = Math.max(max,i + nums[i]);
            if (max >= n - 1) return true;
        }
        return max >= n - 1;
    }
}
